﻿using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 将收到的数据根据reg表达式解析并赋值给targets
/// </summary>
public class Parser : MonoBehaviour {
    public Text[] targets;
    public string[] regs;
    private void Start()
    {
        MCNetSocket.OnRec += (data, count) =>
        {
            string s = Encoding.ASCII.GetString(data, 0, count);
            for (int i = 0; i < targets.Length; i++)
            {
                if (Regex.IsMatch(s, regs[i]))
                    targets[i].text = T.getMatch(s, regs[i]);
            }
        };
    }
}
